/*
 * Jmeno.java
 *
 * Created on 25. květen 2007, 21:29
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package servissimulator;


import java.io.IOException;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author jirka
 */
public class Jmeno {
    Random random;
    /** Creates a new instance of Jmeno
     *
     */
    public Jmeno()  {
        random = new Random();
  }
    
    /**
     *
     * @return name
     */
    public String getFirstName(){
        try     {
            com.csvreader.CsvReader reader_jmeno = new com.csvreader.CsvReader("data/muzi_jmeno.csv");
            
            reader_jmeno.readHeaders();
            int index = random.nextInt(100);
            while(index!=0 && reader_jmeno.readRecord())
                index--;
            
            String name = reader_jmeno.get("jmeno");
            reader_jmeno.close();
            return name;
            
        } catch (IOException ex) {
            Logger.getLogger("global").log(Level.SEVERE, null, ex);
            return "xx";
        }
        
    }
    
        /**
         * 
         * @return 
         */
        public String getLastName(){
        try     {
            com.csvreader.CsvReader reader_jmeno = new com.csvreader.CsvReader("data/muzi_prijmeni.csv");
            
            reader_jmeno.readHeaders();
            int index = random.nextInt(100);
            while(index!=0 && reader_jmeno.readRecord())
                index--;
            
            String name = reader_jmeno.get("jmeno");
            reader_jmeno.close();
            return name;
            
        } catch (IOException ex) {
            Logger.getLogger("global").log(Level.SEVERE, null, ex);
            return "xx";
        }
        
    }
    
        
          /**
         * 
         * @return 
         */
        public String getTitle(){
        try     {
            com.csvreader.CsvReader reader_jmeno = new com.csvreader.CsvReader("data/tituly.csv");
            
            reader_jmeno.readHeaders();
            int index = random.nextInt(60);
            while(index!=0 && reader_jmeno.readRecord())
                index--;
            
            String name = reader_jmeno.get("jmeno");
            reader_jmeno.close();
            return name;
            
        } catch (IOException ex) {
            Logger.getLogger("global").log(Level.SEVERE, null, ex);
            return "xx";
        }
        
    }
        
        public String getRandomPhoneNumber(){
        return ""+(random.nextInt(9)+1)+
                ""+random.nextInt(10)+""
                +random.nextInt(10)+""
                +random.nextInt(10)+""
                +random.nextInt(10)+""
                +random.nextInt(10)+""
                +random.nextInt(10)+""
                +random.nextInt(10)+""+
                random.nextInt(10);
        }
}
